#include "stdio.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "unistd.h"
#include "linux/input.h"

int main(int argc, char *argv[])
{
    struct input_absinfo info;
    int fd;
    int max_slots;

    if ( argc != 2 ) {
        fprintf(stderr, "usage:%s<input-dev>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fd = open(argv[1], O_RDONLY)) < 0 ) {
        perror("open error");
        exit(EXIT_FAILURE);
    }

    if ((fd = ioctl(fd, EVIOCGABS(ABS_MT_SLOT), &info)) < 0 ) {
        perror("ioctl error");
        close(fd);
        exit(EXIT_FAILURE);
    }

    max_slots = info.maximum + 1 - info.minimum;

    printf("max_slots: %d\n", max_slots);

    close(fd);
    exit(EXIT_SUCCESS);
}